{extend name="Public:base" /}
      {block name="seo"}
              <title>发布帖子|{$Think.CONFIG.WEB_SITE_TITLE} - Powered by EasySNS!</title>
  
  
  <meta name="keywords" content="{$Think.CONFIG.WEB_SITE_KEYWORD}">
  <meta name="description" content="{$Think.CONFIG.WEB_SITE_DESCRIPTION}">
      {/block}
{block name="body"}
<div class="aw-container-wrap">
	<div class="container aw-publish">
		<div class="row">
			<div class="aw-content-wrap clearfix">
				<div class="aw-main-content">
					<!-- tab 切换 -->
					<ul class="nav nav-tabs aw-nav-tabs active">
																								
						<h2 class="hidden-xs"><i class="iconfont icon-comment"></i> 发布帖子</h2>
						
						<a href="{:es_url('index/pointrule')}" target="_blank" class="pull-right">[积分规则]</a>
					</ul>
					<!-- end tab 切换 -->
			<form class="form-horizontal" id="topicaddform" >
												<div class="aw-mod aw-mod-publish">
												
							<div class="mod-body es-padded-t-20">
							
							<div class="form-group">
    <label for="" class="col-sm-1 control-label">标题:</label>
    <div class="col-sm-8">
     <input type="text" placeholder="标题..." name="title" id="title" value="" class="form-control">
    </div>
  </div>
  <div class="form-group">
    <label for="" class="col-sm-1 control-label">帖子分类:</label>
    <div class="col-sm-8">
    <select name="tid" id="tid" class="form-control">
    
    {volist name="topiccatelist" id="vo"}
    
    <option value="{$vo.id}">{$vo.name}</option>
    {/volist}
    
    </select>
    
    
    </div>
  </div>
		<div class="form-group">
    <label for="" class="col-sm-1 control-label">话题:</label>
   
    <div class="row col-sm-11">


  <div class="col-xs-4">
     <input type="text" class="form-control" id="tpt_input" autocomplete="off" placeholder="创建或搜索添加新话题...">
  </div>
    <div class="col-xs-2">
     <button class="btn btn-default " id="tpt_btn" type="button" >添加</button>
  </div>
</div>
    
  
   
  </div>	
   <div class="form-group">
    <div class="col-sm-offset-1 col-sm-10">
    							<input type="hidden" name="gidtext" value="{$name}">
							    	<div id="tpt_sel" class="tpt_sels" style="display: block;">
    <span>
			</span>
    </div>
     	<div id="tpt_pre" class="  keyword-sug-wrap tpt_pres" style="display: block;">
       
        <p style="margin:0;">
       {volist name="cateinfo" id="vo"}
        <span class="item-tag"><a href="javascript:;">{$vo.name}</a></span>
        {/volist}
        
        </p></div>
    </div>
  </div>				

        
        						
				<div class="form-group">
    <label for="" class="col-sm-1 control-label">内容:	</label>
    <div class="col-sm-11">
       <textarea name="content" placeholder="" id="content" rows="15" ></textarea>
       {:hook('ArticleEditor', array('name'=> 'content','number'=>10000,'value'=> '','items'=>'','editor_height'=>'300'))}
    </div>
  </div>	
  					 {:hook('Topicfileadd', array('fileid'=>'','max_number' => 10,'img_upload_url'=>es_url('File/fileUpload')))}	
	<div class="form-group">
    <div class="col-sm-offset-1 col-sm-10">
      <button type="button" data-url="{:es_url('topic/topicadd')}" class="btn btn-success topicadd ajax-post"><i class="iconfont icon-comment" style="color:#fff;"></i> 发布帖子</button>
     
    </div>
  </div>		
																
								
						
								


 
 
 
																															</div>
		
						</div>
					</form>
				</div>

			</div>
		</div>
	</div>
</div>
   


 
                   

 {/block}		
{block name="script"}


 <link rel="stylesheet" href="__JS__/jquery.autocompleter.css">
 
        <script src="__JS__/jquery.autocompleter.js"></script>
<script>

$(function(){
	var dataurl="{:es_url('Ajaxinfo/gethtlist')}";
	$( "#tpt_input" ).autocompleter({ source: dataurl,
		mustMatch:true,
		matchSubset:false,

	       
	});
	var name = "gidtext";
	var tags = $.trim($("input[name=" + name + "]").val());
	if (tags !== "") {
		tags = tags.split(",");
	} else {
		tags = new Array();
	}
	$.each(tags, function(k, v) {
		$("#tpt_sel").children('span').append('<a href="javascript:;">' + v + '<i class="iconfont icon-cuowu"></i></a>');
	});
	$('#tpt_input').keydown(function(e) {
		if (e.which === 13) {
			$("#tpt_btn").click();
			e.preventDefault();
			return false;
		}
	});
	$("#tpt_sel").on('click', 'a>i', function() {
		var name = "gidtext";
		var tag = $(this).parent().text();
		$(this).parent().remove();
		var tags = new Array();
		$("#tpt_sel").find('a').each(function() {
			tags.push($(this).text());
		});
		$("input[name=" + name + "]").val(tags.join(","));
		$("#tpt_pre a:contains('" + tag + "')").removeClass("selected");
	});
	$("#tpt_btn").click(function() {
		var name = "gidtext";
		var tags = $.trim($("input[name=" + name + "]").val());
		if (tags !== "") {
			tags = tags.split(",");
		} else {
			tags = new Array();
		}
		var tag = $.trim($("#tpt_input").val());
		if (tag !== '' && $.inArray(tag, tags) === -1) {
			tags.push(tag);
			$("#tpt_pre a:contains('" + tag + "')").addClass("selected");
		}
		$("#tpt_sel").children('span').empty();
		$.each(tags, function(k, v) {
			$("#tpt_sel").children('span').append('<a href="javascript:;">' + v + '<i class="iconfont icon-cuowu"></i></a>');
		});
		$("input[name=" + name + "]").val(tags.join(","));
		$("#tpt_input").val('');
	});
	$("#tpt_pre").on('click', 'a:not(.selected)', function() {
		var name = "gidtext";
		var tags = $.trim($("input[name=" + name + "]").val());
		if (tags !== "") {
			tags = tags.split(",");
		} else {
			tags = new Array();
		}
		var tag = $.trim($(this).text());
		if (tag !== '' && $.inArray(tag, tags) === -1) {
			tags.push(tag);
		}
		$("#tpt_sel").children('span').empty();
		$.each(tags, function(k, v) {
			$("#tpt_sel").children('span').append('<a href="javascript:;">' + v + '<i class="iconfont icon-cuowu"></i></a>');
		});
		$("input[name=" + name + "]").val(tags.join(","));
		$(this).addClass('selected');
	});
	$('.topicadd').click(function(){
		
	    $.post($(this).data('url'),$('form#topicaddform').serialize(),function(data){
	    	
		      if(data.code == 1){
		       
		        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
		          location.href="{:es_url('user/mytopic')}";
		        });
		      }else{
		       
		        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
		        
		       
		        
		      }
		    });
		    return false;
		
		
	});
	
	
});
</script>


{/block}